package cn.edu.scau.dropship.mapper;

import cn.edu.scau.dropship.entity.Parameter;
import cn.edu.scau.dropship.entity.ParameterExample;
import java.util.List;
import org.apache.ibatis.annotations.Arg;
import org.apache.ibatis.annotations.ConstructorArgs;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

public interface ParameterMapper {
    @SelectProvider(type=ParameterSqlProvider.class, method="countByExample")
    long countByExample(ParameterExample example);

    @DeleteProvider(type=ParameterSqlProvider.class, method="deleteByExample")
    int deleteByExample(ParameterExample example);

    @Delete({
        "delete from parameter",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id);

    @Insert({
        "insert into parameter (id, param_pk, ",
        "param_value, param_description, ",
        "admin_id)",
        "values (#{id,jdbcType=INTEGER}, #{paramPk,jdbcType=VARCHAR}, ",
        "#{paramValue,jdbcType=DOUBLE}, #{paramDescription,jdbcType=VARCHAR}, ",
        "#{adminId,jdbcType=INTEGER})"
    })
    int insert(Parameter record);

    @InsertProvider(type=ParameterSqlProvider.class, method="insertSelective")
    int insertSelective(Parameter record);

    @SelectProvider(type=ParameterSqlProvider.class, method="selectByExample")
    @ConstructorArgs({
        @Arg(column="id", javaType=Integer.class, jdbcType=JdbcType.INTEGER, id=true),
        @Arg(column="param_pk", javaType=String.class, jdbcType=JdbcType.VARCHAR),
        @Arg(column="param_value", javaType=Double.class, jdbcType=JdbcType.DOUBLE),
        @Arg(column="param_description", javaType=String.class, jdbcType=JdbcType.VARCHAR),
        @Arg(column="admin_id", javaType=Integer.class, jdbcType=JdbcType.INTEGER)
    })
    List<Parameter> selectByExample(ParameterExample example);

    @Select({
        "select",
        "id, param_pk, param_value, param_description, admin_id",
        "from parameter",
        "where id = #{id,jdbcType=INTEGER}"
    })
    @ConstructorArgs({
        @Arg(column="id", javaType=Integer.class, jdbcType=JdbcType.INTEGER, id=true),
        @Arg(column="param_pk", javaType=String.class, jdbcType=JdbcType.VARCHAR),
        @Arg(column="param_value", javaType=Double.class, jdbcType=JdbcType.DOUBLE),
        @Arg(column="param_description", javaType=String.class, jdbcType=JdbcType.VARCHAR),
        @Arg(column="admin_id", javaType=Integer.class, jdbcType=JdbcType.INTEGER)
    })
    Parameter selectByPrimaryKey(Integer id);

    @UpdateProvider(type=ParameterSqlProvider.class, method="updateByExampleSelective")
    int updateByExampleSelective(@Param("record") Parameter record, @Param("example") ParameterExample example);

    @UpdateProvider(type=ParameterSqlProvider.class, method="updateByExample")
    int updateByExample(@Param("record") Parameter record, @Param("example") ParameterExample example);

    @UpdateProvider(type=ParameterSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(Parameter record);

    @Update({
        "update parameter",
        "set param_pk = #{paramPk,jdbcType=VARCHAR},",
          "param_value = #{paramValue,jdbcType=DOUBLE},",
          "param_description = #{paramDescription,jdbcType=VARCHAR},",
          "admin_id = #{adminId,jdbcType=INTEGER}",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(Parameter record);
}